﻿using System.Data.Entity.ModelConfiguration;

namespace Delphi.Mimir.Data.Entities.Raw.Mappings {

    public class RawQuoteMap : EntityTypeConfiguration<RawQuote> {
        public RawQuoteMap() {
            /******************************************************************
            /* Table
            /*****************************************************************/
            ToTable("raw.eod_quotes");

            /******************************************************************
            /* Primary Key
            /*****************************************************************/
            HasKey(a => a.qot_id);

            /******************************************************************
            /* Index
            /*****************************************************************/
            // None

            /******************************************************************
            /* Relationships
            /*****************************************************************/
            // None
            
            /******************************************************************
            /* Properties
            /*****************************************************************/
            Property(a => a.qot_id)
                .IsRequired()
                .HasColumnName("qot_id");

            Property(a => a.qot_sym_cd)
                .IsRequired()
                .IsUnicode(false)
                .HasMaxLength(25)
                .HasColumnName("qot_sym_cd");

            Property(a => a.qot_exc_cd)
                .IsRequired()
                .IsUnicode(false)
                .HasMaxLength(25)
                .HasColumnName("qot_exc_cd");

            Property(a => a.qot_trade_dt)
                .IsRequired()
                .HasColumnName("qot_trade_dt");

            Property(a => a.qot_period)
                .IsRequired()
                .IsUnicode(false)
                .HasMaxLength(25)
                .HasColumnName("qot_period");

            Property(a => a.qot_open)
                .IsRequired()
                .HasPrecision(18, 6)
                .HasColumnName("qot_open");

            Property(a => a.qot_high)
                .IsRequired()
                .HasPrecision(18, 6)
                .HasColumnName("qot_high");

            Property(a => a.qot_low)
                .IsRequired()
                .HasPrecision(18, 6)
                .HasColumnName("qot_low");

            Property(a => a.qot_close)
                .IsRequired()
                .HasPrecision(18, 6)
                .HasColumnName("qot_close");

            Property(a => a.qot_volume)
                .IsOptional()
                .HasColumnName("qot_volume");

            Property(a => a.qot_open_interest)
                .IsOptional()
                .HasColumnName("qot_open_interest");

            Property(a => a.qot_adj_factor)
                .IsOptional()
                .HasPrecision(18, 6)
                .HasColumnName("qot_adj_factor");
        }
    }
}
